package com.youhong.teethcare

import android.os.Bundle
import android.util.Log
import android.view.View
import android.webkit.WebChromeClient
import android.webkit.WebSettings
import android.webkit.WebView
import kotlinx.android.synthetic.main.activity_privacy.*

class PrivacyActivity : BaseActivity() {
    companion object {
        const val Key_url = "Key_url"
        const val Key_urlType = "Key_urlType"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_privacy)
        initStatusBar(resources.getColor(R.color.pageBackground), true)
        initWebView()
    }
    private  val TAG = "PrivacyActivity"
    fun initWebView() {
        val url = intent.getStringExtra(Key_url)
        val webSettings: WebSettings = webViewPrivacy.getSettings()
        webSettings.javaScriptEnabled = true
        webSettings.allowFileAccess = true
        webSettings.allowFileAccessFromFileURLs = true
        webSettings.allowUniversalAccessFromFileURLs = true
        webSettings.setSupportZoom(true) //缩放开关，设置此属性，仅支持双击缩放，不支持触摸缩放
        webSettings.builtInZoomControls = true //设置是否可缩放，会出现缩放工具（若为true则上面的设值也默认为true）
        webSettings.displayZoomControls = false
        webSettings.domStorageEnabled = true
        webViewPrivacy.loadUrl(url!!)
        webViewPrivacy.webChromeClient = object : WebChromeClient() {
            override fun onProgressChanged(view: WebView, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                progressBar.progress=newProgress
               if(newProgress==100)progressBar.visibility=View.INVISIBLE

                Log.i(TAG, "onProgressChanged: "+newProgress)
            }
        }

        aboutUs_iv_back.setOnClickListener {
            finish()
        }
    }
}